//
//  BelowView.m
//  我的音频播放器
//
//  Created by dllo on 16/7/28.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "BelowView.h"

@implementation BelowView


- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self resetAllSubviews];
    }
    return self;
}

-(void)dealloc{
    [_playBtn release];
    [_progressSlider release];
    [_timeIntervalProgress release];
    [_currentTimeLabel release];
    [_totalDurationLabel release];
    [super dealloc];
}


- (void)resetAllSubviews{
    
    
    
    self.timeIntervalProgress = [[UIProgressView alloc]init];
    self.timeIntervalProgress.backgroundColor = [UIColor purpleColor];
    // 下面的颜色
    self.timeIntervalProgress.trackTintColor = BSLightGrayColor;
    // 上面的颜色
    self.timeIntervalProgress.progressTintColor = BSDarkGrayColor;
    [self addSubview:self.timeIntervalProgress];
    [_timeIntervalProgress release];
    
    
    _progressSlider = [[UISlider alloc]init];
    _progressSlider.backgroundColor = BSClearColor;
    
    // 改变Slider的滑块大小
    [_progressSlider setThumbImage:[UIImage imageNamed:@"icon_progress"] forState:UIControlStateNormal];
    [_progressSlider setThumbImage:[UIImage imageNamed:@"icon_progress"] forState:UIControlStateHighlighted];
    
    // 进度条右面颜色为空
    _progressSlider.maximumTrackTintColor = BSClearColor;
    _progressSlider.minimumTrackTintColor = BSRedColor;
    [self addSubview:_progressSlider];
    [_progressSlider release];
    
    
    
    _currentTimeLabel = [[UILabel alloc]init];
    _currentTimeLabel.backgroundColor = BSClearColor;
    _currentTimeLabel.font = [UIFont systemFontOfSize:13.0];
    _currentTimeLabel.textAlignment = NSTextAlignmentRight;
    _currentTimeLabel.textColor = BSWhiteColor;
    [self addSubview:_currentTimeLabel];
    [_currentTimeLabel release];
    
    
    // 显示总时间
    _totalDurationLabel = [[UILabel alloc]init];
    _totalDurationLabel.backgroundColor = BSClearColor;
    _totalDurationLabel.font = [UIFont systemFontOfSize:13.0];
    _totalDurationLabel.textAlignment = NSTextAlignmentLeft;
    _totalDurationLabel.textColor = BSWhiteColor;
    [self addSubview:_totalDurationLabel];
    [_totalDurationLabel release];
    
    
    
    _playBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    _playBtn.alpha = 0.8;
    _playBtn.layer.cornerRadius = 55/2;
    _playBtn.layer.masksToBounds = YES;
    [_playBtn setImage:[UIImage imageNamed:@"音乐播放.png"] forState:UIControlStateNormal];
    [self addSubview:_playBtn];
}


// 高给40 宽 414 - 20
- (void)layoutSubviews
{
    [super layoutSubviews];
    CGFloat btnWidth = self.bounds.size.height + 15; // 70
    
    _playBtn.frame = CGRectMake(5, - 15/2, btnWidth, btnWidth);
    
    
    _timeIntervalProgress.bounds = CGRectMake(0,0,self.bounds.size.width - 60,10);
    _timeIntervalProgress.center = CGPointMake(self.bounds.size.width / 2.0 + 30, 0);
    
    _progressSlider.bounds = CGRectMake(0,0,self.bounds.size.width - 60,10);
    _progressSlider.center = CGPointMake(self.bounds.size.width / 2.0 + 30 , 0);
    
    _currentTimeLabel.frame = CGRectMake(70,20,60,20);
    
    _totalDurationLabel.frame = CGRectMake(self.bounds.size.width - 60,20,60,20);
    
}


@end
